<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>${projectName}</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<script type="text/javascript" src='<c:url value="/js/boot.js"></c:url>'></script>
<link rel="stylesheet" type="text/css"
	href='<c:url value="/share/styles.css"></c:url>' />
<style type="text/css">
body, html {
	width: 100%;
	height: 100%;
	margin: 0;
	font-family: "微软雅黑";
}

#detailPan {
	width: 100%;
	height: 100%;
}

p {
	margin-left: 5px;
	font-size: 14px;
}

body {
	height: 100%;
	overflow: hidden;
}

.filterPan td {
	padding: 0;
}

.level1Class {
	margin-left: 10px;
}

.level2Class {
	margin-left: 30px;
}

.level3Class {
	margin-left: 50px;
}

.deepDark {
	background-color: #CCC488;
}

.normalDark {
	background-color: #FFF7BB;
}

.lowDark {
	
}

.mini-splitter-pane {
	overflow: auto;
}

.mini-panel-body {
	padding: 0;
}

html body .searchbox .mini-buttonedit-icon {
	background: url('<c:url value="/share/img/magnifier-zoom.png"></c:url>')
		no-repeat 5% 5%;
}

.nameTitle {
	color: red;
}
</style>
<script type="text/javascript">
	var radioValue = [ {
		id : 1,
		text : "在职"
	}, {
		id : 0,
		text : "已离职"
	} ];
	var sexData = [ {
		id : 1,
		text : "男"
	}, {
		id : 0,
		text : "女"
	} ];
	var natureData = [ {
		id : 1,
		text : "长期"
	}, {
		id : 0,
		text : "短期"
	} ];
</script>

</head>
<body>
	<div class="mini-toolbar" id="toolbarId"
		style="padding: 0px; border-width: 1px; border-bottom-width: 0px;">
		<table style="width: 100%;">
			<tr>
				<td style="width: 5px; height: 23px;"></td>
				<td><div id="typeBtn" class="mini-radiobuttonlist" 
						repeatItems="1" repeatLayout="table" repeatDirection="vertical"
						style="float: left; margin-top: 4px;" textField="text"
						valueField="id" value="1" onvaluechanged="chageState"
						data="radioValue"></div></td>
			</tr>
		</table>
	</div>
	<div class="mini-fit">
		<div id="datagrid1" class="mini-datagrid gridFull"
			borderStyle="border:1;" showReloadButton="true" pagesize="100"
			sizeList="[20,50,100,200]" allowCellWrap="true"
			allowHeaderWrap="true" idField="No" multiSelect="true"
			showPager="true" allowAlternating="true"
			ondrawcell="ondatagridDrawCell" onrowdblclick="gridRowDbClick"
			style="height: 100%; width: 100%; -moz-user-select: none; -webkit-user-select: none;"
			collapseGroupOnLoad="false" showColumnsMenu="true"
			showFilterRow="true" onshowrowdetail="onShowRowDetail">
			<div property="columns">
				<div type="indexcolumn" width="40px"></div>
				<div field="Action" width="70px" headerAlign="center" align="center">
					<a class="mini-button" property="filter" id="removeBtn"
						iconCls="icon-broom" tooltip="清除筛选" onclick="removeSearch">清除
					</a>
				</div>
				<div field="OrgName" width="200px" headerAlign="center" align="left"
					allowSort="true">
					所属公司<input id="filter1" property="filter" class="mini-combobox"
						style="width: 100%;" url="<c:url value='/org/list' />"
						textField="OrgName" valueField="OrgNo" onValueChanged="onselect"
						emptyText="筛选..." onenter="onselect" />
				</div>
				<div field="CardID" width="200px" headerAlign="center" align="left"
					allowSort="true">
					身份证号<input id="filter2" property="filter"
						class="mini-buttonedit searchbox" style="width: 100%;"
						onbuttonclick="onselect" emptyText="筛选..." onenter="onselect" />
				</div>
				<div field="UserName" width="80px" headerAlign="center" align="left"
					allowSort="true">
					姓名<input id="filter3" property="filter"
						class="mini-buttonedit searchbox" style="width: 100%;"
						onbuttonclick="onselect" emptyText="筛选..." onenter="onselect" />
				</div>
				<div field="Sex" width="80px" headerAlign="center" align="center"
					allowSort="true">
					性别<input id="filter4" property="filter" class="mini-combobox"
						style="width: 100%;" data="sexData" onValueChanged="onselect"
						emptyText="筛选..." onenter="onselect" />
				</div>
				<div field="EmployTypeName" width="80px" headerAlign="center"
					align="left" allowSort="true">
					工种<input id="filter5" property="filter" class="mini-combobox"
						textField="EmployType" valueField="TypeNo" style="width: 100%;"
						url="<c:url value='/common/type/employ_type'></c:url>"
						onValueChanged="onselect" emptyText="筛选..." onenter="onselect" />
				</div>
				<div field="Nature" width="80px" headerAlign="center"
					align="left" allowSort="true">
					性质<input id="filter6" property="filter" class="mini-combobox"
						style="width: 100%;" data="natureData" onValueChanged="onselect"
						emptyText="筛选..." onenter="onselect" />
				</div>
				<div field="EmployTime" width="140px" dateFormat="yyyy-MM-dd HH:mm"
					headerAlign="center" align="center" allowSort="true">入职时间</div>
				<div name="emptyCol" width='100%' headerAlign="center"
					align="center" cellStyle="padding:0;"></div>
			</div>
		</div>
	</div>

	<script type="text/javascript">
		mini.parse();
		mini_debugger = false;
		var isKeepStat3 = false;

		var rootPath = '${rootPath}';

		var filterHelper = gridFilter();

		var datagrid1 = mini.get("datagrid1");
		var filter1 = mini.get("filter1");
		var filter2 = mini.get("filter2");
		var filter3 = mini.get("filter3");
		var filter4 = mini.get("filter4");
		var filter5 = mini.get("filter5");
		var filter6 = mini.get("filter6");

		var typeBtn = mini.get("typeBtn");

		$(function() {
			mini.get("toolbarId").hide();
			loadGrid1();
		});
		function onselect() {
			var filterValue1 = filter1.getValue();
			var filterValue2 = filter2.getValue();
			var filterValue3 = filter3.getValue();
			var filterValue4 = filter4.getValue();
			var filterValue5 = filter5.getValue();
			var filterValue6 = filter6.getValue();
			if (filterValue1 != "") {
				var filterdata = filterHelper.formFilterData("OrgNo",
						filterValue1, '', 'EQUALS', 'AND');
				filterHelper.addFilterData(filterdata);
			}
			if (filterValue2 != "") {
				var filterdata = filterHelper.formFilterData("CardID",
						filterValue2, '', 'CONTAIN', 'AND');
				filterHelper.addFilterData(filterdata);
			}
			if (filterValue3 != "") {
				var filterdata = filterHelper.formFilterData("UserName",
						filterValue3, '', 'CONTAIN', 'AND');
				filterHelper.addFilterData(filterdata);
			}
			if (filterValue4 != "") {
				var filterdata = filterHelper.formFilterData("Sex",
						filterValue4, '', 'EQUALS', 'AND');
				filterHelper.addFilterData(filterdata);
			}
			if (filterValue5 != "") {
				var filterdata = filterHelper.formFilterData("EmployType",
						filterValue5, '', 'EQUALS', 'AND');
				filterHelper.addFilterData(filterdata);
			}
			if (filterValue6 != "") {
				var filterdata = filterHelper.formFilterData("Nature",
						filterValue6, '', 'EQUALS', 'AND');
				filterHelper.addFilterData(filterdata);
			}
			loadGrid1();
		}
		function removeSearch() {
			filter1.setValue();
			filter2.setValue();
			filter2.setText();
			filter3.setValue();
			filter3.setText();
			filter4.setValue();
			filter5.setValue();
			filter6.setValue();
			filterHelper.clearFilterData();
			loadGrid1();
		}
		function chageState() {
			loadGrid1();
		}
		function loadGrid1() {
			var filterData = filterHelper.getFilterData();
			var postData = new Object();
			if (filterData != null || filterData.length > 0) {
				postData.filterdata = mini.encode(filterData);
			}
			var state = typeBtn.getValue();
			var url = "<c:url value='/referral/list/' />" + state;
			datagrid1.load(url);
			datagrid1.load(postData);
		}
		function ondatagridDrawCell(e) {
			var row = e.row;
			var field = e.field;
			if (field == "Action") {
				var id = row.EmployId;
				e.cellHtml = '<a class="aTagUnderLine" href="javascript:check('
						+ id + ')">[详细]</a>';
			} 
			if (field == "Sex") {
				var value = e.value;
				if (typeof value=='number') {
					e.cellHtml = (value == 1) ? '男' : '女';
				}
			}
			if (field == "Nature") {
				var value = e.value;
				if(typeof value == 'number'){
					if(value==1){
						e.cellHtml =  '长期';
					}else{
						e.cellHtml =  '短期';
					}
				}
			}
		}
		function gridRowDbClick(e){
			var row = e.row;
			if(!row) return;
			check(row.EmployId);
		}
		function check(id) {
			var url = "<c:url value='/user/check/' />"+id;
			mini.open({
				url : url,
				title : '查看员工详细信息',
				width : 800,
				height : 600,
				onload : function() {
					/* var iframe = this.getIFrameEl();
					var data = {
					}; */
					//iframe.contentWindow.SetData(data);
				},
				ondestroy : function(action) {
					if (action == 'ok') {
						//reloadList();
					}
				}
			});
		}
		function reloadList() {
			datagrid1.reload();
		}
	</script>
</body>
</html>